SEVEN SEGMENT DISPLAY INTERFACING WITH AVR
This AVR tutorial will discuss interfacing a Seven Segment Display with the AVR 8-bit ATmega16 microcontroller. A Seven Segment Display is just seven LEDs arranged and packaged in a configuration.
Synopsis

A seven-segment display is a form of electronic display device for displaying decimal numbers (and some alphabets too). SSD may use a liquid crystal display (LCD), a light-emitting diode (LED) for each segment, or other light-generating or controlling techniques such as cold cathode gas discharge, vacuum fluorescent, incandescent filaments, and other.

This AVR tutorial will discuss interfacing a Seven Segment Display with the AVR 8-bit ATmega16 microcontroller. A Seven Segment Display is just seven LEDs arranged and packaged in a configuration.

Description

The seven LEDs in the seven segment display are labelled with the letters A, B, C, D, E. F and G as indicated in Fig 2 below. Some seven segment display may include 1 or 2 additional LEDs which are used as decimal point(s).


Seven Segment Displays are mainly used to display numerical digits. The figure below shows which LEDs to turn ON to display the digits 1, 2, 3, 4, 5 and 6. Other numbers can be displayed by turning ON the appropriate LEDs.


A Seven Segment Display can also be used to display certain letters of alphabet. The figure below gives the LEDs to turn ON to display A, F, H, L and P.


Since these are basically LEDs arranged as a group they can either have anode in common or cathode thus they are named as Common-Anode/Common-Cathode displays.

Common Cathode: In this type of segments all the cathode terminals are made common and tied to GND. Thus the segments a to g needs a logic High signal (5v) in order to glow. This is shown in figure (5). 

Common Anode: In this type of segments all the anodes terminals are made common and tied to VCC (5v). Thus the segments a to g needs a logic LOW signal (GND) in order to glow. This is shown in figure(6).

Applications:

Seven segment are widely used in applications where digits[0-9] are required to be displayed. Although they also display letters A to F as shown in figure(2) simulation. This is a very simple and convenient way to display numbers in a bright fashion.

Proteus design for Seven Segment interfacing with AVR


Orcad design for Seven Segment interfacing with AVR


Seven Segment interfacing with AVR

/*  Name     : Main.c
 *  Purpose  : Source code for SEGMENT Interfacing with ATMEGA16.
 *  Author   : GEMICATES
 *  Date     : 10-07-2017
 *  Website  : www.gemicates.org
 *  Revision : None
 */

#include <avr/io.h>				// Header File for ATMEGA16
#include <util/delay.h>			        // Include Delay Function

void main()
{
DDRD=0xff;				        // To Set PORT D as Output Port
	while (1)				// Infinte loop

	{
                                                // Turn ON Each Segment in the Order Of A-H

			PORTD = 0xFE;		// 'A' segment turn on
			_delay_ms(500);
			PORTD = 0xFD;		// 'B' segment turn on
			_delay_ms(500);
			PORTD = 0xFB;		// 'C' segment turn on
			_delay_ms(500);
			PORTD = 0xF7;		// 'D' segment turn on
			_delay_ms(500);
			PORTD = 0xEF;		// 'E' segment turn on
			_delay_ms(500);
			PORTD = 0xDF;		// 'F' segment turn on
			_delay_ms(500);
			PORTD = 0xBF;		// 'G' segment turn on
			_delay_ms(500);
			PORTD = 0x7F;		// 'H' segment turn on
			_delay_ms(500);
		
			                        // Default 'H' segment turn ON

			PORTD = 0x40;		// Display '0'
			_delay_ms(500);
			PORTD  = 0x79;		// Display '1'
			_delay_ms(500);
			PORTD  = 0x24;		// Display '2'
			_delay_ms(500);
			PORTD  = 0x30;		// Display '3'
			_delay_ms(500);
			PORTD  = 0x19;		// Display '4'
			_delay_ms(500);
			PORTD  = 0x12;		// Display '5'
			_delay_ms(500);
			PORTD  = 0x02;		// Display '6'
			_delay_ms(500);
			PORTD  = 0x78;		// Display '7'
			_delay_ms(500);
			PORTD  = 0x00;		// Display '8'
			_delay_ms(500);
			PORTD  = 0x10;		// Display '9'
			_delay_ms(500);
		
			                        // Default 'H' segment turn OFF

			PORTD  = 0xC0;		// Display '0'
			_delay_ms(500);
			PORTD  = 0xF9;		// Display '1'
			_delay_ms(500);
			PORTD  = 0xA4;		// Display '2'
			_delay_ms(500);
			PORTD  = 0xB0;		// Display '3'
			_delay_ms(500);
			PORTD  = 0x99;		// Display '4'
			_delay_ms(500);
			PORTD  = 0x92;		// Display '5'
			_delay_ms(500);
			PORTD  = 0x82;		// Display '6'
			_delay_ms(500);
			PORTD  = 0xF8;		// Display '7'
			_delay_ms(500);
			PORTD  = 0x80;		// Display '8'
			_delay_ms(500);
			PORTD  = 0x90;		// Display '9'
			_delay_ms(500);

		}
}


Error message here!

Show Error message here!


Forgot your password?

Error message here!

Send OTP

Error message here!

Show Error message here!


Lost your password? Please enter your email address. You will receive a password you Need.

Send Error message here!


Back to log-in

Close